package com.ympc.service.impl;

import com.ympc.mapper.CourseMapper;
import com.ympc.pojo.Course;
import com.ympc.service.CourseService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    
    @Resource
    private CourseMapper courseMapper;
    
    @Override
    public List<Course> getCoursesByTeacherId(Integer teacherId) {
        return courseMapper.findByTeacherId(teacherId);
    }
    
    @Override
    public Course getCourseById(Integer id) {
        return courseMapper.findById(id);
    }
    
    @Override
    public List<Course> getCoursesByClassId(Integer classId) {
        return courseMapper.findByClassId(classId);
    }
    
    @Override
    public boolean createCourse(Course course) {
        return courseMapper.insertCourse(course) > 0;
    }
    
    @Override
    public boolean updateCourse(Course course) {
        return courseMapper.updateCourse(course) > 0;
    }
    
    @Override
    public boolean deleteCourse(Integer id) {
        return courseMapper.deleteCourse(id) > 0;
    }
}

